#pragma once

#include "DirectedRelationship.h"

#include "Element.h"

namespace uml {

void DirectedRelationship::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Relationship::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(sources_, "sources", json, errorList);
    JsonSerializable::fromJsonArray(targets_, "targets", json, errorList);
}

void DirectedRelationship::toJson(QJsonObject& json) {
    Relationship::toJson(json);
    JsonSerializable::toJsonArray(sources_, "sources", json);
    JsonSerializable::toJsonArray(targets_, "targets", json);
}

/// <summary>
/// sources getter
/// Specifies the source Element(s) of the DirectedRelationship.
/// </summary>
vector<shared_ptr<Element>>& DirectedRelationship::sources() {
    return sources_;
}

/// <summary>
/// targets getter
/// Specifies the target Element(s) of the DirectedRelationship.
/// </summary>
vector<shared_ptr<Element>>& DirectedRelationship::targets() {
    return targets_;
}

} // namespace uml
